<%@ page contentType="text/html;charset=utf-8" language="java"
	pageEncoding="UTF-8" import="java.util.Date"%>
<!DOCTYPE html>
<html lang="en">
<head>
<%@include file="/WEB-INF/jsp/common/style.jsp"%>


</head>
<body>
	<div id="wrap">

		<form class="form-horizontal" id="seachform"
			action="${pageContext.request.contextPath}/set/project/index"
			method="post">
			<input type="hidden" name="catId" /> <input type="hidden"
				name="catLevel" />
			<div class="container-fluid">

				<!-- Main window -->
				<div class="main_container" id="dashboard_page">

					<div class="row-fluid">
						<div class="widget widget-padding span12">
							<h4 class="widget-head-title">项目管理</h4>
							<div class="widget-header">
								<span>首页&nbsp;>&nbsp;项目管理</span>
							</div>
							<div class="row-fluid"
								style="background-color: #fff; padding: 20px 20px;">
								<div class="table-scroll">
									<table
											style="line-height: 40px; text-align: left; padding: 20px 20px">
										<tr>
											<td width="70px">项目名称:</td>
											<td><input name="projectName"
													   value="${model.projectName}" type="text" class="" /></td>
											<td width="70px">创建时间:</td>
											<td><input readOnly=true class="Wdate" type="text"
													   name="startTime" id="d17" value="${model.startTime}"
													   onFocus="WdatePicker({dateFmt:'yyyy/MM/dd'})" />
												&nbsp;&nbsp;&nbsp;&nbsp;-&nbsp;&nbsp;&nbsp;&nbsp;</td>
											<td width="70px">至</td>
											<td><input readOnly=true class="Wdate" type="text"
													   name="endTime" id="d18" value="${model.endTime}"
													   onFocus="WdatePicker({dateFmt:'yyyy/MM/dd'})" /></td>
											<td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>

										</tr>

									</table>
								</div>
							</div>
						</div>
					</div>

					<div class="row-fluid">
						<div>
							<input class="btn btn-primary" type="submit" value="查询" /> <input
								class="btn btn-success buttonrole" type="button" name="btnadd"
								onclick="edit('')" value="新增" />

						</div>
					</div>
					<div class="row-fluid">
						<div class="widget widget-padding span12">
							<div class="widget-header">
								<i class="icon-group"></i>
								<h5>查询结果</h5>

							</div>
							<div class="widget-body">
								<div class="table-scroll">
									<table id="users"
										   class="table table-striped table-bordered dataTable">
										<thead>
										<tr>
											<th>项目ID</th>
											<th>项目名称</th>
											<th>创建人</th>
											<th>创建时间</th>
											<th>操作</th>
										</tr>
										</thead>
										<tbody>
										<tr>
											<c:forEach items="${model.items}" var="item"
													   varStatus="itemStatus">
										<tr id="row_${item.id}">
											<td>${item.id}</td>
											<td>${item.projectName}</td>
											<td>${item.createUserName}</td>
											<td><fmt:formatDate value="${item.createTime}"
																type="both" pattern="yyyy-MM-dd HH:mm:ss" /></td>

											<td align="center" align="center"><a
													href="javascript:edit('${item.id}');" name="btnedit"
													class="buttonrole" style="margin-left: 5px">编辑</a> <a
													href="javascript:del('${item.id}');" class="buttonrole" name="btndel"
													style="margin-left: 5px">删除</a></td>
										</tr>
										</c:forEach>
										</tr>

										</tbody>
									</table>
								</div>
							</div>
							<!-- /widget-body -->
							 <div class="pagin" class="widget-footer">
					             	<vp:pages  cpage="${model.cpage}"  totalCount="${model.totalCount}"  pageSize="${model.pageSize}"   />
					   		</div>   
						</div>
						<!-- /widget -->
					</div>
					<!-- /row-fluid -->
					<!-- /Main window -->

				</div>
			</div>
		</form>
	</div>
	<!-- wrap ends-->

	<div id="edit"
		style="display: none; width: 100%; height: 100%; overflow: hidden; position: absolute; left: 0; top: 0; right: 0; bottom: 0;">
		<iframe id="editFrame" width="100%" height="100%" frameborder="0"
			border="0" scrolling="auto"></iframe>
	</div>

</body>
<script type="text/javascript">
	function seach() {
		$("#cpage").val(1);
		oksubmit();
	}
	function oksubmit() {
		$("#btnOk").attr("disabled", "disabled");
		var objform = document.getElementById('seachform');
		objform.submit();
	}
	function del(id) {
		layer.confirm('确认要删除此项目吗', {
			btn : [ '确认', '取消' ]
		//按钮
		}, function() {
			sendOpTo(id);
		}, function() {

		});
	}
	function sendOpTo(id) {
		layer.load(1, {
			shade : [ 0.5, '#fff' ]
		});
		var postData = "projectId=" + id;
		$.ajax({
			type : "POST",
			url : "del",
			data : postData,
			contentType : "application/x-www-form-urlencoded;charset=UTF-8",
			async : true, // 同步  true 异步。默认是异步
			dataType : 'json',
			error : function(resultdata) {
				layer.closeAll();
			},
			success : function(resultdata) {
				layer.closeAll();
				if (resultdata.returnCode == "0000") {
					layer.alert('操作成功', {
						icon : 1
					}, function() {
						layer.closeAll();
						oksubmit();
					});
				} else {
					layer.alert(resultdata.returnMessage);
				}
			}
		});
	}

	function editReturn() {
		layer.closeAll();
		oksubmit();
	}
	function closeAll() {
		layer.closeAll();
	}
	function edit(id) {
		var domainUrl = "edit?projectId=" + id;
		layer.open({
			type : 2,
			title : '项目',
			area : [ '600px', '450px' ],
			content : domainUrl
		//iframe的url
		});
	}
</script>
</html>
